package cn.le.netty.handler;

import cn.le.netty.util.ConnectionUtil;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

/**
 * 登录netty服务器
 */
public class ActiveHandler extends ChannelInboundHandlerAdapter {

    private String ip;
    private int port;

    public ActiveHandler(String ip, int port){
        this.ip = ip;
        this.port = port;
    }

    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
        System.out.println("--------触发channelActive");
        ConnectionUtil.active(ip,port,ctx);//根据ip和端口记录nettyServer链接
        ctx.fireChannelActive();
    }

}
